
<%@page import="java.util.Iterator"%>
<%@page import="cs4280.bean.Booking"%>
<%@page import="java.util.ArrayList"%>
<script type="text/javascript">
    function applyRefund(obj) {
                var i,myObj;
                myObj=document.getElementsByName(obj);
                for(i=0;i<myObj.length;i++){
                    if(myObj[i].checked)break;
                };
                if(i>=myObj.length){
                    alert("Please choose one method to apply refund.");
                    return false;
                } else {
                    return true;
                }
            }
</script>


<form name="frmPage" id="frmPage" method="post" onsubmit="return applyRefund('bookingid')" action="/assignmentCinema/">
    <input type="hidden" name="todo" id="todo" value="doapplyrefund" />

    <table>
        <thead>
            <tr>
                <th>Select</th>
                <th>Movie</th>
                <th>Seating</th>
                <th>Payment</th>
            </tr>
        </thead>
        <tbody>
            <%

                        ArrayList<Booking> bookings =
                                (ArrayList<Booking>) request.getAttribute("bookings");
                        Iterator<Booking> it = bookings.iterator();
                        while (it.hasNext() != false) {
                            pageContext.setAttribute("booking", (Booking) it.next());
            %>
            <jsp:useBean id="booking" type="cs4280.bean.Booking" scope="page"/>

            <% if (booking.getRequest() == 0) {
            %>

            <tr>
                <td><input type="radio" name="bookingid" value="<%=booking.getId()%>"/> </td>
                <td><%=booking.getMoviename()%></td>
                <td><%=booking.getSeating()%></td>
                <td><%=booking.getPayment()%></td>
            </tr>

            <jsp:scriptlet>
                            }
                        }</jsp:scriptlet>


        </tbody>

    </table>

    <input type="submit" value="Apply" />
   <input type="button" name="btnSubmit" value="cancel" onclick="document.getElementById('todo').value='';" />
</form>

